package com.wang.leetcode;

/**
 * @Author: along
 * @Create: 2021/4/17 12:38
 * @Description:对称的二叉树
 */
public class Sword28 {
    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }

    public boolean isSymmetric(TreeNode root) {
        if (root == null) {
            return true;
        }
        return process(root.left, root.right);
    }

    boolean process(TreeNode L, TreeNode R) {
        if (L == null && R == null) return true;
        if (L == null || R == null || L.val != R.val) return false;
        return process(L.left, R.right) && process(L.right, R.left);
    }
}
